<%@page contentType="text/html;charset=UTF-8"%>
<%@page pageEncoding="UTF-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ include file="/pub/includ.jsp"%>
<script type="text/javascript">
	var save = function(){
		var flag = "failure";
		if($.formValidator.pageIsValid()){
			var options = {
				type: 'POST',
				async: false,
				dataType: 'content-type',
				success: function(msg) {
					flag = msg;
				}
			}
			$('#codeform').ajaxSubmit(options);
		}
		return flag;
	}
	
	$(document).ready(function(){
	    $.formValidator.initConfig({formid:"codeform",alertmessage:false,onerror:function(msg){alert(msg)}});
	    $("#name").formValidator({}).inputValidator({min:1,max:30,onerror:"编码名称不能为空且不超过30个字符"});
			    
	    
	    $("#code").formValidator({}).inputValidator({min:1,max:10,onerror:"编码不能为空且不能超过10个字符哦"}).ajaxValidator({
			    type : "get",
				url : "<%=path%>/sys/code/vlcode?code="+document.getElementById("code").value,
				datatype : "html",
				success : function(data){
		            if( data == "success" )
					{
		                return true;
					}
		            else
					{
		                return false;
					}
				},
				onerror : "该编码名已注册不可用，请更换编码名",
				onwait : "正在对编码名进行合法性校验，请稍候..."
			}).defaultPassed();;
	  $("#order_num").formValidator({}).inputValidator({min:1,max:3,onerror:"排序号必须在0-999之间，请确认"}).regexValidator({regexp:"^[0-9]*$",onerror:"排序号错误"});
	    });
	    
	    
	    
       /* $.formValidator.initConfig({
			                      onerror: function(msg){
			                      alert('错误');
        }});
        $("#name").formValidator({
                }).inputValidator({
                    min: 1,
                    onerror: "编码名称不能为空,请确认"
                }).inputValidator({
                    max:30,
                    onerror: "编码名称不能超过30个字符"
                });
        $("#code").formValidator({
		        }).inputValidator({
		            min: 1,
		            onerror: "编码不能为空,请确认"
		        }).inputValidator({
		            max:10,
		            onerror: "编码不能超过10个字符"
		        });
        $("#order_num").formValidator({
                })
                .inputValidator({
                    min:0,max:999,type:"value",
                    onerrormin:"你输入的值必须大于等于1",
                    onerror:"排序号必须在0-999之间，请确认"
                 });
	})*/
</script>
<form id="codeform" action="<%=path %>/sys/code/save" method="post">
<table><tr><td height="2px"></td></tr></table>
<table align="center" border="0" cellpadding="0" cellspacing="1" class="table_nbw" >
	<tr >
		<td align="right" width="40%" height=25 style="background-color:f2f9ff">上级编码：</td>
		<td align="left" width="60%" style="background-color:fff">&nbsp;<input class="textfiled_nbw"  type="text" id="pname" name="pname" value="${pdata.name}"></td>
	</tr>
	<tr>
		<td align="right" height=25 style="background-color:f2f9ff">编码名称：</td>
		<td align="left" style="background-color:fff">&nbsp;<input class="textfiled_nbw"  type="text" id="name" name="name" value="${data.name}"><span style="color:red;font-weight:bold">*</span></td>
	</tr>
	<tr>
		<td align="right" height=25 style="background-color:f2f9ff">编码：</td>
		<td align="left"  style="background-color:fff">&nbsp;<input class="textfiled_nbw"  type="text" id="code" name="code" value="${data.code}"><span style="color:red;font-weight:bold">*</span></td>
	</tr>
	<tr>
		<td align="right" height=25 style="background-color:f2f9ff">编码类型：</td>
		<td align="left" style="background-color:fff">&nbsp;<input class="textfiled_nbw"  type="text" id="type" name="type" value="${data.type}"></td>
	</tr>
	<tr>
		<td align="right" height=25 style="background-color:f2f9ff">参数1：</td>
		<td align="left"  style="background-color:fff">&nbsp;<input class="textfiled_nbw"  type="text" id="pam1" name="pam1" value="${data.pam1}"></td>
	</tr>
	<tr>
		<td align="right" height=25 style="background-color:f2f9ff">参数2：</td>
		<td align="left" style="background-color:fff">&nbsp;<input class="textfiled_nbw"  type="text" id="pam2" name="pam2" value="${data.pam2}"></td>
	</tr>
	<tr>
		<td align="right" height=25 style="background-color:f2f9ff">描述：</td>
		<td align="left"  style="background-color:fff">&nbsp;<input class="textfiled_nbw"  type="text" id="code_describe" name="code_describe" value="${data.code_describe}"></td>
	</tr>
	<tr>
		<td align="right" height=25 style="background-color:f2f9ff">备注：</td>
		<td align="left" style="background-color:fff">&nbsp;<input class="textfiled_nbw"  type="text" id="remarks" name="remarks" value="${data.remarks}"></td>
	</tr>
	<tr>
		<td align="right" height=25 style="background-color:f2f9ff">排序号：</td>
		<td align="left"  style="background-color:fff">&nbsp;<input class="textfiled_nbw"  type="text" id="order_num" name="order_num" value="${data.order_num}"><span style="color:red;font-weight:bold">*</span></td>
	</tr>
</table>
<table width="100%"><tr><td align="center">
			<input type=hidden name="id" value="${data.id}" />
			<input type=hidden name="parent_id" value="${data.parent_id}" />
			<input type=hidden name="ptree_id" value="${pdata.tree_id}" />
			<input type=hidden name="tree_id" value="${data.tree_id}" />
			<input type=hidden name="valid_flag" value="${data.valid_flag}" />	
</td></tr></table>
</form>

